﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KinectControl
{
    /// <summary>
    /// Interaction logic for Tutorial.xaml
    /// </summary>
    public partial class Tutorial : UserControl
    {
        public event EventHandler FinalizaTutorial;

        public Tutorial()
        {
            InitializeComponent();                        
        }

        private void videoTutorial_MediaEnded(object sender, RoutedEventArgs e)
        {
            this.videoTutorial.Source = new Uri(this.PathVideo, UriKind.RelativeOrAbsolute);
            this.videoTutorial.Position = TimeSpan.FromSeconds(0);
            this.videoTutorial.Play();
        }



        public string PathVideo
        {
            get { return (string)GetValue(PathVideoProperty); }
            set { SetValue(PathVideoProperty, value); }
        }

        // Using a DependencyProperty as the backing store for PathVideo.  
        // This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PathVideoProperty =
            DependencyProperty.Register("PathVideo",
                                        typeof(string),
                                        typeof(Tutorial),
                                        new PropertyMetadata(string.Empty,
                                            new PropertyChangedCallback(OnPathVideoChanged)));

        static void OnPathVideoChanged(object sender, DependencyPropertyChangedEventArgs args)
        {
            // Get reference to self
            Tutorial source = (Tutorial)sender;

            // Add Handling Code
            string newValue = (string)args.NewValue;            
            source.videoTutorial.Source = new Uri(newValue, UriKind.RelativeOrAbsolute);
            source.videoTutorial.Position = TimeSpan.FromSeconds(0);
            source.videoTutorial.Play();            
        }
                
    }
}
